package svc

import (
	"api/internal/config"
	"api/internal/middleware"
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"goods_srv/goodssrvclient"
)

type ServiceContext struct {
	Config              config.Config
	GoodsSrv            goodssrvclient.Goodssrv
	UserLoginMiddleware rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:              c,
		GoodsSrv:            goodssrvclient.NewGoodssrv(zrpc.MustNewClient(c.GoodsSrv)),
		UserLoginMiddleware: middleware.NewUserLoginMiddleware().Handle,
	}
}
